package com.ssm.study.controller;

import com.ssm.study.entity.Admin;
import com.ssm.study.entity.User;
import com.ssm.study.service.IAdminService;
import com.ssm.study.service.IUserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServlet;
import java.util.List;

/**
 * Created by w on 2017/4/16.
 */

@Controller
@RequestMapping("/user")
public class UserController extends HttpServlet {

    @Resource
    IUserService userService;


    @RequestMapping(value = "list", method = RequestMethod.GET)
    @ResponseBody
    public ModelAndView adminList() {
        ModelAndView mav = new ModelAndView("userinfo");

        List<User> userList = userService.getAllUsers();

        mav.addObject("userList", userList );

        return mav;
    }

  //  @RequestMapping("/list")
  //  @ResponseBody
  //  public List<User> userList() {
   //     return userService.getAllUsers();
   // }


}
